GdkPixbuf *pixbuf,
gdouble x,
gdouble y);
+static void render_background_internal (GtkThemingEngine *engine,
+ cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ GtkJunctionSides junction,
+ cairo_pattern_t *optional_background);
G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
GtkBorderStyle border_style;
GtkBorder border;
gint border_width;
+ GtkStylePropertyContext context;
+ cairo_pattern_t *pattern;
flags = gtk_theming_engine_get_state (engine);
cairo_save (cr);
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
gtk_theming_engine_get_border (engine, flags, &border);
- gtk_theming_engine_get (engine, flags,
- "border-style", &border_style,
- NULL);
+ context.width = width;
+ context.height = height;
+
+ _gtk_theming_engine_get (engine, flags, &context,
+ "background-image", &pattern,
+ "border-style", &border_style,
+ NULL);
+
+ if (pattern != NULL)
+ {
+ render_background_internal (engine, cr, x, y, width, height,
+ gtk_theming_engine_get_junction_sides (engine), pattern);
+ cairo_restore (cr);
+ cairo_pattern_destroy (pattern);
+ return;
+ }
border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
gint exterior_size, interior_size, pad, thickness, border_width;
GtkBorderStyle border_style;
GtkBorder border;
+ GtkStylePropertyContext context;
+ cairo_pattern_t *pattern;
flags = gtk_theming_engine_get_state (engine);
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
gtk_theming_engine_get_border (engine, flags, &border);
- gtk_theming_engine_get (engine, flags,
- "border-style", &border_style,
- NULL);
+ context.width = width;
+ context.height = height;
+
+ _gtk_theming_engine_get (engine, flags, &context,
+ "background-image", &pattern,
+ "border-style", &border_style,
+ NULL);
+
+ if (pattern != NULL)
+ {
+ render_background_internal (engine, cr, x, y, width, height,
+ gtk_theming_engine_get_junction_sides (engine), pattern);
+ cairo_restore (cr);
+ cairo_pattern_destroy (pattern);
+ return;
+ }
exterior_size = MIN (width, height);
border_width = MIN (MIN (border.top, border.bottom),
gtk_symbolic_color_unref (shade);
}
+/* optional_background is the background-image, in case it was
+ already availible we avoid getting it (and thus possibly
+ rendering it) twice */
static void
render_background_internal (GtkThemingEngine *engine,
cairo_t *cr,
gdouble y,
gdouble width,
gdouble height,
- GtkJunctionSides junction)
+ GtkJunctionSides junction,
+ cairo_pattern_t *optional_background)
{
GdkRGBA bg_color;
cairo_pattern_t *pattern;
context.width = width;
context.height = height;
+ if (optional_background)
+ pattern = cairo_pattern_reference (optional_background);
+ else
+ _gtk_theming_engine_get (engine, flags, &context,
+ "background-image", &pattern,
+ NULL);
+
_gtk_theming_engine_get (engine, flags, &context,
- "background-image", &pattern,
"background-repeat", &repeat,
"box-shadow", &box_shadow,
NULL);
other_flags = flags | GTK_STATE_FLAG_PRELIGHT;
gtk_theming_engine_get_background_color (engine, other_flags, &other_bg);
- gtk_theming_engine_get (engine, other_flags,
- "background-image", &other_pattern,
- NULL);
+ _gtk_theming_engine_get (engine, other_flags, &context,
+ "background-image", &other_pattern,
+ NULL);
if (pattern && other_pattern)
{
render_background_internal (engine, cr,
x, y, width, height,
- junction);
+ junction, NULL);
}
static void
gap_side == GTK_POS_BOTTOM)
render_background_internal (engine, cr,
0, 0, width, height,
- GTK_JUNCTION_BOTTOM);
+ GTK_JUNCTION_BOTTOM, NULL);
else
render_background_internal (engine, cr,
0, 0, height, width,
- GTK_JUNCTION_BOTTOM);
+ GTK_JUNCTION_BOTTOM, NULL);
cairo_restore (cr);
cairo_save (cr);
color_shade (&bg_color, 0.7, &darker);
color_shade (&bg_color, 1.3, &lighter);
- render_background_internal (engine, cr, x, y, width, height, sides);
+ render_background_internal (engine, cr, x, y, width, height, sides, NULL);
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
{